package com.alingrad.android.test.cyborghuman;

import javax.microedition.khronos.opengles.GL10;

import com.alingrad.android.froyoengine.Game;
import com.alingrad.android.froyoengine.collisions.Collidable;
import com.alingrad.android.froyoengine.collisions.CollisionMask;
import com.alingrad.android.froyoengine.graphics.renderable.Square;
import com.alingrad.android.froyoengine.tree.GameObject;

public class JumpObstacle extends GameObject implements Collidable {
	private Square mSquare;
	private boolean mAlive;
	private CollisionMask mMask;
	
	@Override
	public void load(GL10 gl) {
		mSquare = new Square(120);
		mAlive = true;
	}
	
	public JumpObstacle() {
		super();
		mMask = new CollisionMask();
	}
	
	public void initialize(int x) {
		mX = 1000f;
		mY = 100;
		mAlive = true;
	}

	@Override
	public void update(long delta) {
		mX -= 100 * delta / 1000f;
		
		if (mX < -150) {
			mAlive = false;
		}else {
			mMask.update(mSquare.getCollisionMaskData(), mX, mY);
			Game.sRenderManager.scheduleToRender(mSquare, mX, mY, -5f, 0f);
		}
	}

	@Override
	public boolean isAlive() {
		return mAlive;
	}

	@Override
	public CollisionMask getCollisionMask() {
		return mMask;
	}

}
